package com.amigo.online.provider.user.mapper;

import com.amigo.online.common.param.result.UserInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import com.amigo.online.common.core.mybatis.MyMapper;
import com.amigo.online.provider.user.model.entity.InviteCode;

@Mapper
@Component
public interface InviteCodeMapper extends MyMapper<InviteCode> {

    @Select("select code from invite_code_tbl where user_id = #{userId} and deleted = 0 limit 1")
    String getCodeByUserId(Long userId);

    @Select("select id,user_id,code,created_time,updated_time,deleted,deleted_time"
            + " from invite_code_tbl where code = #{code} and deleted = 0 limit 1")
    InviteCode getByCode(String code);

    @Select("select id,user_id,code,created_time,updated_time,deleted,deleted_time"
            + " from invite_code_tbl where user_id = #{userId} and deleted = 0 limit 1")
    InviteCode getByUserId(Long userId);
}
